
 
 F u n c t i o n :   i m p o r t ( E x t e r n a l R e s o u r c e s ,   C o n f i g O b j e c t ,   C o n t e x t N o d e ) 
 
 
 
 S h o r t h a n d 1 :   i m p o r t ( E x t e r n a l R e s o u r c e s ,   C a l l b a c k F u n c t i o n ) 
 
 
 
 S h o r t h a n d 2 :   i m p o r t ( E x t e r n a l R e s o u r c e s ,   C o n f i g O b j e c t ,   C a l l b a c k F u n c t i o n ) 
 
 
 
 D e s c r i p t i o n :   L o a d s   o n e   o r   m o r e   e x t e r n a l   s c r i p t s ,   s t y l e s h e e t s ,   o r   i m a g e s   i n t o   t h e   c u r r e n t   d o c u m e n t   w i t h i n   t h e   s p e c i f i e d   d o m E l e m e n t .   D i f f e r s   f r o m   $ A . g e t S c r i p t   b y   u t i l i z i n g   t h e   n a t i v e   F e t c h   A P I   f o r   f a s t e r   p r o c e s s i n g   a n d   m o r e   g r a n u l a r   c o n t r o l . 
 
 
 
 R e t u r n s :   d o m E l e m e n t ,   o r   $ A   o b j e c t   i f   c h a i n e d . 
 
 
 
 N o t e :   T h e   C o n f i g O b j e c t   p a r a m e t e r   c a n   b e   u s e d   t o   s e t   m a n u a l   o v e r r i d e s   f o r   c u s t o m   f u n c t i o n a l i t y .   T h e   C o n t e x t N o d e   p a r a m e t e r   c a n   b e   u s e d   t o   s e t   a   c u s t o m   D O M   e l e m e n t   w h e r e   i m p o r t e d   t a g   e l e m e n t s   a r e   a p p e n d e d .   W h e n   t h e   " n a m e "   p r o p e r t y   i s   s e t   w i t h i n   C o n f i g O b j e c t ,   t h e   r e f e r e n c e d   m o d u l e   c o d e   w i l l   b e   i m p o r t e d   a n d   t h e n   e x e c u t e d   d y n a m i c a l l y   i f   i t   h a s   n o t   b e e n   i m p o r t e d   p r e v i o u s l y ,   t h e n   a l l   s u b s e q u e n t   i m p o r t   s t a t e m e n t s   w i t h   t h e   s a m e   n a m e   w i l l   c a u s e   t h e   m o d u l e   c a l l b a c k   s t a t e m e n t   t o   b e   e x e c u t e d   w i t h o u t   h a v i n g   t o   i m p o r t   t h e   e x t e r n a l   m o d u l e   c o d e   a g a i n . 
 
 
 
 E x t e r n a l R e s o u r c e s   ( a r g u m e n t ) 
 
 
 
 T h e   e x t e r n a l   r e s o u r c e s   p a r a m e t e r   m a y   c o n t a i n   a n   a b s o l u t e   o r   r e l a t i v e   f i l e   p a t h   s t r i n g ,   o r   i t   m a y   c o n t a i n   a n   a r r a y   o f   m u l t i p l e   f i l e   p a t h s . 
 
 
 
 A l t e r n a t i v e l y ,   t h e   $ A . m o d u l e F o l d e r   p a t h   c a n   b e   s e t   t o   r e f e r e n c e   t h e   f o l d e r   p a t h   w h e r e   4 X   m o d u l e   f i l e s   a r e   l o c a t e d .   W h e n   t h i s   i s   d o n e ,   m o d u l e   f i l e s   c a n   b e   l o a d e d   s i m p l y   b y   r e f e r e n c i n g   t h e   f i l e   n a m e   f o r   e a c h   m o d u l e ,   w h e t h e r   a s   a   s t r i n g   t o   p u l l   i n   o n e   m o d u l e ,   o r   a s   a n   a r r a y   o f   m o d u l e   n a m e s   t o   i m p o r t   a l l   a t   o n c e .   W h e n   d o i n g   t h i s ,   i t   i s   n o t   n e c e s s a r y   t o   i n c l u d e   " . j s "   a t   t h e   e n d   o f   e a c h   m o d u l e   n a m e   r e f e r e n c e .   E x a m p l e s :   " A c c o r d i o n " ,   o r   [ " A c c o r d i o n " ,   " B e e p " ,   " D a t e p i c k e r " ,   . . . ] 
 
 
 
 F o r   h e l p   c o n f i g u r i n g   t h e   d e f a u l t   " m o d u l e F o l d e r "   p a t h ,   v i e w   t h e   h e l p   f i l e   a t :   " H e l p / M o d u l e   I n t r o   a n d   U s a g e " 
 
 
 
 C o n f i g O b j e c t   ( a r g u m e n t ) 
 
 
 
 S y n t a x : 
 
 
 
 { 
 
 
 
     / /   D e f e r   c a l l   f u n c t i o n   e x e c u t i o n   u n t i l   a f t e r   t h e   p a g e   c o m p l e t e s   l o a d i n g . 
 
     / /   W h e n   t r u e ,   a l l   e x t e r n a l   m o d u l e s   w i l l   l o a d   i n s t a n t l y   t o   m a x i m i z e   s p e e d ,   b u t   t h e   a s s o c i a t e d   c a l l   f u n c t i o n   w i l l   b e   d e f e r r e d . 
 
     d e f e r :   f a l s e ,   / /   D e f a u l t 
 
 
 
     / /   S e t   a   u n i q u e   n a m e   f o r   t h e   i m p o r t   s t a t e m e n t . 
 
     / /   W h e n   s p e c i f i e d ,   e x t e r n a l   m o d u l e s   f o r   t h i s   i m p o r t   s t a t e m e n t   w i l l   b e   l o a d e d   o n l y   o n c e ,   a f t e r   w h i c h   t h e   c a l l   f u n c t i o n   w i l l   a l w a y s   b e   e x e c u t e d   i m m e d i a t e l y .   
 
     / /   N o t e :   T h i s   f u n c t i o n a l i t y   i s   s e p a r a t e   f r o m   c a c h i n g ,   w h i c h   w i l l   s t i l l   e x e c u t e   t h e   p r e v i o u s l y   l o a d e d   m o d u l e   c o d e   w h e n   c a l l e d   a g a i n   e v e n   w h e n   s t o r e d   i n t e r n a l l y . 
 
     n a m e :   " " ,   / /   E m p t y   b y   d e f a u l t . 
 
 
 
     / /   S p e c i f y   t h a t   t h e   i m p o r t e d   m o d u l e   c o d e   w i l l   b e   e x e c u t e d   o n l y   o n c e ,   a f t e r   w h i c h   i t   w i l l   n o t   b e   e x e c u t e d   a g a i n   e v e n   i f   t h e   s a m e   i m p o r t   s t a t e m e n t   i s   r u n   r e p e a t e d l y . 
 
     o n c e :   f a l s e , 
 
 
 
     / /   M a y   b e   s e t   a s   a   l o c a l i z e d   o v e r r i d e   o f   t h e   $ A . n o C a c h e   p r o p e r t y ,   w h e r e   i m p o r t   c a c h i n g   c a n   b e   t e m p o r a r i l y   e n a b l e d   o r   d i s a b l e d   a s   n e e d e d . 
 
         n o C a c h e :   f a l s e , 
 
 
 
     / /   S e t   c u s t o m   p r o p s   t h a t   w i l l   b e   p a s s e d   i n t o   t h e   s c o p e   o f   e v e r y   d y n a m i c a l l y   l o a d e d   m o d u l e . 
 
     / /   W h e n   s e t ,   " p r o p s "   i s   a u t o m a t i c a l l y   d e c l a r e d   w i t h i n   t h e   s c o p e   o f   a l l   e x t e r n a l l y   l o a d e d   m o d u l e   c o d e ,   w h i c h   m a y   i n   t u r n   b e   p a s s e d   i n t o   o t h e r   i m p o r t   s t a t e m e n t s   t o   p a s s   d a t a   d o w n   t h e   c h a i n   o f   e a c h   m o d u l e . 
 
     / /   T o   b e t t e r   u n d e r s t a n d   h o w   t h e   p r o p s   o b j e c t   w o r k s ,   v i e w   t h e   h e l p   f i l e   " P r o p s . t x t " . 
 
     p r o p s :   { 
 
         / /   S e t   c u s t o m   p r o p e r t i e s   a n d   m e t h o d s   t o   p a s s   i n t o   e a c h   e x t e r n a l   m o d u l e   t h r o u g h   ' p r o p s ' . 
 
     } , 
 
 
 
     / /   E x e c u t e   a   c a l l b a c k   a f t e r   a l l   e x t e r n a l   r e s o u r c e s   c o m p l e t e   l o a d i n g . 
 
     c a l l :   f u n c t i o n ( p r o p s ,   r e t u r n e d V a l u e )   { 
 
         / /   D o   s o m e t h i n g   a f t e r   t h e   e x t e r n a l   r e s o u r c e s   l o a d . 
 
         / /   r e t u r n e d V a l u e   i s   p o p u l a t e d   w h e n   a n   i m p o r t e d   m o d u l e   i n c l u d e s   a   r e t u r n   s t a t e m e n t   w i t h i n   i t . 
 
     } , 
 
 
 
     / /   W h e n   i m p o r t i n g   a n   a r r a y   o f   m u l t i p l e   r e s o u r c e s ,   s p e c i f y   t h a t   t h e   c a l l   f u n c t i o n   w i l l   r u n   a f t e r   e a c h   i m p o r t   c o m p l e t e s   l o a d i n g . 
 
     / /   O t h e r w i s e ,   o n l y   d o   s o   a f t e r   a l l   r e s o u r c e s   f i n i s h   l o a d i n g . 
 
     c a l l O n A l l :   f a l s e , 
 
 
 
     / /   O p t i o n a l l y   o v e r r i d e   a l l   f u n c t i o n a l i t y   w i t h i n   t h e   i n t e r n a l   F e t c h   g e t   m e t h o d   f o r   e v e r y   u r l   b e i n g   i m p o r t e d . 
 
     o v e r r i d e :   { 
 
         d a t a :   { 
 
             / /   O p t i o n s :   " h t m l " ,   " t e x t " ,   " x m l " ,   " j s o n " 
 
             r e t u r n T y p e :   " t e x t " , 
 
             / /   S e t s   a   C S S   q u e r y   s e l e c t o r   t o   r e t u r n   t h e   f i r s t   m a t c h i n g   n o d e   w i t h i n   t h e   n e w l y   l o a d e d   h t m l   o r   x m l . 
 
             s e l e c t o r :   " " , 
 
             / /   F e t c h   A P I   
 
             m e t h o d :   " G E T " , 
 
             h e a d e r s :   { } ,   / /   r e q u e s t   h e a d e r s .   f o r m a t   i s   t h e   i d e n t i c a l   t o   t h a t   a c c e p t e d   b y   t h e   H e a d e r s   c o n s t r u c t o r 
 
             b o d y :   n u l l ,   / /   r e q u e s t   b o d y .   c a n   b e   n u l l ,   a   s t r i n g ,   a   B u f f e r ,   a   B l o b ,   o r   a   N o d e . j s   R e a d a b l e   s t r e a m 
 
             c a c h e :   " d e f a u l t " ,   / /   T h e   c a c h e   m o d e   y o u   w a n t   t o   u s e   f o r   t h e   r e q u e s t :   d e f a u l t ,   n o - s t o r e ,   r e l o a d ,   n o - c a c h e ,   f o r c e - c a c h e ,   o r   o n l y - i f - c a c h e d . 
 
             r e d i r e c t :   " f o l l o w " ,   / /   T h e   r e d i r e c t   m o d e   t o   u s e :   f o l l o w   ( a u t o m a t i c a l l y   f o l l o w   r e d i r e c t s ) ,   e r r o r   ( a b o r t   w i t h   a n   e r r o r   i f   a   r e d i r e c t   o c c u r s ) ,   o r   m a n u a l   ( h a n d l e   r e d i r e c t s   m a n u a l l y ) .   I n   C h r o m e   t h e   d e f a u l t   i s   f o l l o w   ( b e f o r e   C h r o m e   4 7   i t   d e f a u l t e d   t o   m a n u a l ) . 
 
             k e e p a l i v e :   f a l s e ,   / /   T h e   k e e p a l i v e   o p t i o n   c a n   b e   u s e d   t o   a l l o w   t h e   r e q u e s t   t o   o u t l i v e   t h e   p a g e .   F e t c h   w i t h   t h e   k e e p a l i v e   f l a g   i s   a   r e p l a c e m e n t   f o r   t h e   N a v i g a t o r . s e n d B e a c o n ( )   A P I . 
 
             m o d e :   ' c o r s ' ,   / /   T h e   m o d e   y o u   w a n t   t o   u s e   f o r   t h e   r e q u e s t ,   e . g . ,   c o r s ,   n o - c o r s ,   o r   s a m e - o r i g i n . 
 
             c r e d e n t i a l s :   ' o m i t ' ,   / /   T h e   r e q u e s t   c r e d e n t i a l s   y o u   w a n t   t o   u s e   f o r   t h e   r e q u e s t :   o m i t ,   s a m e - o r i g i n ,   o r   i n c l u d e .   T o   a u t o m a t i c a l l y   s e n d   c o o k i e s   f o r   t h e   c u r r e n t   d o m a i n ,   t h i s   o p t i o n   m u s t   b e   p r o v i d e d .   S t a r t i n g   w i t h   C h r o m e   5 0 ,   t h i s   p r o p e r t y   a l s o   t a k e s   a   F e d e r a t e d C r e d e n t i a l   i n s t a n c e   o r   a   P a s s w o r d C r e d e n t i a l   i n s t a n c e . 
 
             r e f e r r e r :   ' c l i e n t ' ,   / /   A   U S V S t r i n g   s p e c i f y i n g   n o - r e f e r r e r ,   c l i e n t ,   o r   a   U R L .   T h e   d e f a u l t   i s   c l i e n t . 
 
             r e f e r r e r P o l i c y :   ' n o - r e f e r r e r ' ,   / /   S p e c i f i e s   t h e   v a l u e   o f   t h e   r e f e r e r   H T T P   h e a d e r .   M a y   b e   o n e   o f   n o - r e f e r r e r ,   n o - r e f e r r e r - w h e n - d o w n g r a d e ,   o r i g i n ,   o r i g i n - w h e n - c r o s s - o r i g i n ,   u n s a f e - u r l . 
 
             s i g n a l :   n u l l ,   / /   A n   A b o r t S i g n a l   o b j e c t   i n s t a n c e ;   a l l o w s   y o u   t o   c o m m u n i c a t e   w i t h   a   f e t c h   r e q u e s t   a n d   a b o r t   i t   i f   d e s i r e d   v i a   a n   A b o r t C o n t r o l l e r . 
 
             i n t e g r i t y :   n u l l   / /   C o n t a i n s   t h e   s u b r e s o u r c e   i n t e g r i t y   v a l u e   o f   t h e   r e q u e s t   ( e . g . ,   s h a 2 5 6 - B p f B w 7 i v V 8 q 2 j L i T 1 3 f x D Y A e 2 t J l l u s R S Z 2 7 3 h 2 n F S E = ) . 
 
         } , 
 
         s u c c e s s :   f u n c t i o n ( c o n t e n t ,   p r o m i s e ) {         } , 
 
         e r r o r :   f u n c t i o n ( e r r o r ,   p r o m i s e ) {         } 
 
     } 
 
 
 
 } 
 
 
 
 C o n t e x t N o d e   ( a r g u m e n t ) 
 
 
 
 T h e   C o n t e x t N o d e   p a r a m e t e r   c a n   b e   o p t i o n a l l y   s e t   t o   l o a d   i m p o r t e d   c o n t e n t   i n t o   s p e c i f i c   D O M   n o d e   c o n t a i n e r   e l e m e n t s   w h e n   n e e d e d .   T h i s   i s   o f t e n   u s e d   w h e n   i m p o r t i n g   C S S   s t y l e s h e e t s . 
 
 
 
 C a l l b a c k F u n c t i o n   ( a r g u m e n t ) 
 
 
 
 T h e   s p e c i f i e d   c a l l b a c k   f u n c t i o n   w i l l   e x e c u t e   a f t e r   t h e   r e f e r e n c e d   m o d u l e   o r   m o d u l e   a r r a y   h a s   c o m p l e t e d   l o a d i n g . 
 
 
 
 E x a m p l e : 
 
 
 
 / /   L o a d   a n   e x t e r n a l   m o d u l e   a n d   e x e c u t e   a   c a l l b a c k   f u n c t i o n   u s i n g   s h o r t h a n d   s y n t a x . 
 
 $ A . i m p o r t (   s t r i n g P a t h T o I m p o r t ,   f u n c t i o n ( )   { 
 
     / /   D o   s o m e t h i n g   a f t e r   t h e   i m p o r t e d   m o d u l e s   c o m p l e t e   l o a d i n g . 
 
 } ) ; 
 
 
 
 / /   L o a d   a n   e x t e r n a l   m o d u l e   a n d   e x e c u t e   a   c a l l b a c k   f u n c t i o n   u s i n g   a l t e r n a t i v e   s h o r t h a n d   s y n t a x . 
 
 $ A . i m p o r t (   [ s t r i n g P a t h s T o I m p o r t ] ,   { d e f e r :   t r u e } ,   f u n c t i o n ( )   { 
 
     / /   D o   s o m e t h i n g   a f t e r   t h e   i m p o r t e d   m o d u l e s   c o m p l e t e   l o a d i n g . 
 
 } ) ; 
 
 
 
 / /   I m p o r t   a   c o l l e c t i o n   o f   m o d u l e s   i n t o   4 X 
 
 $ A . i m p o r t ( [ " A c c o r d i o n " ,   " D a t e p i c k e r " ,   " T a b " ] ) ; 
 
 
 
 / /   I m p o r t   a   c o l l e c t i o n   o f   m o d u l e s   i n t o   4 X   t h a t   w i l l   l o a d   o n l y   o n c e . 
 
 $ A . i m p o r t ( [ " A c c o r d i o n " ,   " D a t e p i c k e r " ,   " T a b " ] ,   {   o n c e :   t r u e   } ) ; 
 
 
 
 / /   I m p o r t   a   s p e c i f i c   m o d u l e   i n t o   4 X   o n c e   a n d   r u n   t h e   a s s o c i a t e d   c a l l b a c k ,   t h e n   i m m e d i a t e l y   e x e c u t e   t h e   s a m e   c a l l b a c k   e v e r y   t i m e   t h e   s a m e   s t a t e m e n t   i s   r u n   w i t h o u t   r e l o a d i n g   t h e   e x t e r n a l   r e s o u r c e   a g a i n . 
 
 $ A . i m p o r t ( " A c c o r d i o n " ,   / /   S p e c i f i e s   t h e   r e f e r e n c e d   m o d u l e   f i l e   n a m e   w i t h i n   t h e   f o l d e r   " / 4 X / M o d u l e s / "   t o   b e   d y n a m i c a l l y   l o a d e d . 
 
     { 
 
         n a m e :   " A c c o r d i o n M o d u l e " ,   / /   S p e c i f y   a   u n i q u e   i d e n t i f i e r   f o r   t h e   i m p o r t   s t a t e m e n t . 
 
         p r o p s :   { 
 
             / /   O p t i o n a l l y   s e t   p r o p e r t i e s   a n d   m e t h o d s   t o   p a s s   i n t o   t h e   n e w l y   l o a d e d   m o d u l e . 
 
         } , 
 
         / /   P r e v e n t   t h e   c a l l   f u n c t i o n   f r o m   e x e c u t i n g   u n t i l   a f t e r   t h e   p a g e   f i n i s h e s   l o a d i n g . 
 
         d e f e r :   t r u e , 
 
         c a l l :   f u n c t i o n ( p r o p s )   { 
 
             / /   E x e c u t e   $ A . s e t A c c o r d i o n ( )   s t a t e m e n t   a f t e r   t h e   m o d u l e   c o d e   i s   l o a d e d . 
 
         } 
 
     } 
 
 ) ; 
 
 